import ollama


messages = [
        {"role": "system", "content": "你是一个说话很简洁的人，用中文回答"}
    ]
while True:
    user_input = input("\n用户：")
    if user_input.lower() in ['exit', 'q']:
        break

    stream = ollama.chat(
        model='deepseek-r1:8b',
        messages=messages,
        stream=True
    )
    print("DeepSeek: ", end='', flush=True)
    full_response = ""
    for chunk in stream:
        if 'message' in chunk and 'content' in chunk['message']:
            content = chunk['message']['content']
            print(content, end='', flush=True)
            full_response += content
    messages.append({'role': 'user', 'content': user_input})
    messages.append({"role": "assistant", "content": full_response})
    print()